package baseFx.springboot;

import baseFx.common.EventDispatcher;

import java.util.UUID;

public class MvcEvents {
    private final String firekey = UUID.randomUUID().toString();
    public final EventDispatcher<RequestEventArgs> requestBefore = new EventDispatcher<>(firekey);
    public final EventDispatcher<RequestEventArgs> requestAfter = new EventDispatcher<>(firekey);
    public final EventDispatcher<HandlerEventArgs> handlerBefore = new EventDispatcher<>(firekey);
    public final EventDispatcher<HandlerEventArgs> handlerAfter = new EventDispatcher<>(firekey);
    public final EventDispatcher<ActionEventArgs> actionBefore = new EventDispatcher<>(firekey);
    public final EventDispatcher<ActionEventArgs> actionAfter = new EventDispatcher<>(firekey);
    public final EventDispatcher<ActionErrorEventArgs> actionError = new EventDispatcher<>(firekey);

    void onHandlerBefore(HandlerEventArgs args) {
        handlerBefore.fire(firekey, null, args);
    }

    void onHandlerAfter(HandlerEventArgs args) {
        handlerAfter.fire(firekey, null, args);
    }

    void onActionBefore(ActionEventArgs args) {
        actionBefore.fire(firekey, null, args);
    }

    void onActionAfter(ActionEventArgs args) {
        actionAfter.fire(firekey, null, args);
    }

    void onActionError(ActionErrorEventArgs args) {
        actionError.fire(firekey, null, args);
    }

    void onReuqestBefore(RequestEventArgs args) {
        requestBefore.fire(firekey, null, args);
    }

    void onReuqestAfter(RequestEventArgs args) {
        requestAfter.fire(firekey, null, args);
    }
}
